package com.situ.mall.controller;

import com.situ.mall.common.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/redis")
public class RedisController {
    @Autowired
    private RedisUtil redisUtil;

    // http://localhost/redis/set?key=study&value=java
    @RequestMapping("/set")
    @ResponseBody
    public String set(String key, String value) {
        redisUtil.set(key, value);
        return  "OK";
    }

    // http://localhost/redis/get?key=study
    @RequestMapping("/get")
    @ResponseBody
    public String get(String key) {
        String value = redisUtil.get(key);
        return value;
    }

}
